//package net.jsoft.platform.security.config.jpa;
//
//import java.util.Properties;
//
//import javax.annotation.Resource;
//import javax.persistence.EntityManagerFactory;
//import javax.sql.DataSource;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
//import org.springframework.orm.jpa.JpaTransactionManager;
//import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
//import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
//import org.springframework.transaction.PlatformTransactionManager;
//
//@Configuration
//@EnableJpaRepositories(entityManagerFactoryRef = "securityEntityManagerFactory", transactionManagerRef = "securityTransactionManager", basePackages =
//{ "net.jsoft.platform.security.repository" })
//public class JpaSecurityConfig
//{
//    @Resource(name = "securityDS")
//    private DataSource ds;
//
//    @Bean(name = "securityEntityManagerFactory")
//    @Autowired
//    @Qualifier("securityDS")
//    public EntityManagerFactory entityManagerFactory(DataSource datasource)
//    {
//        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
//        vendorAdapter.setGenerateDdl(true);
//        vendorAdapter.setShowSql(true);
//        LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
//        factory.setJpaVendorAdapter(vendorAdapter);
//        factory.setDataSource(datasource);
//        factory.setPackagesToScan("net.jsoft.platform.security.entity");
//        Properties jpaProperties = new Properties();
//        jpaProperties.put("hibernate.ejb.naming_strategy", "org.hibernate.cfg.ImprovedNamingStrategy");// 命名策略
//        factory.setJpaProperties(jpaProperties);
//        factory.afterPropertiesSet();
//        return factory.getObject();
//    }
//
//    @Bean(name = "securityTransactionManager")
//    public PlatformTransactionManager transactionManagerSecondary()
//    {
//        JpaTransactionManager txManager = new JpaTransactionManager();
//        txManager.setEntityManagerFactory(entityManagerFactory(ds));
//        return txManager;
//    }
//
//}